#pragma once
#include "OpenGL_Drawable.h"
#include "_GraphData.h"
#include "_GraphLayout.h"
#include <map>

static GLubyte ZoomStipple[] =
{
    0x80, 0x80, 0x80, 0x80,
    0x40, 0x40, 0x40, 0x40,
    0x20, 0x20, 0x20, 0x20,
    0x10, 0x10, 0x10, 0x10,
    0x08, 0x08, 0x08, 0x08,
    0x04, 0x04, 0x04, 0x04,
    0x02, 0x02, 0x02, 0x02,
    0x01, 0x01, 0x01, 0x01,
    0x80, 0x80, 0x80, 0x80,
    0x40, 0x40, 0x40, 0x40,
    0x20, 0x20, 0x20, 0x20,
    0x10, 0x10, 0x10, 0x10,
    0x08, 0x08, 0x08, 0x08,
    0x04, 0x04, 0x04, 0x04,
    0x02, 0x02, 0x02, 0x02,
    0x01, 0x01, 0x01, 0x01,
    0x80, 0x80, 0x80, 0x80,
    0x40, 0x40, 0x40, 0x40,
    0x20, 0x20, 0x20, 0x20,
    0x10, 0x10, 0x10, 0x10,
    0x08, 0x08, 0x08, 0x08,
    0x04, 0x04, 0x04, 0x04,
    0x02, 0x02, 0x02, 0x02,
    0x01, 0x01, 0x01, 0x01,
    0x80, 0x80, 0x80, 0x80,
    0x40, 0x40, 0x40, 0x40,
    0x20, 0x20, 0x20, 0x20,
    0x10, 0x10, 0x10, 0x10,
    0x08, 0x08, 0x08, 0x08,
    0x04, 0x04, 0x04, 0x04,
    0x02, 0x02, 0x02, 0x02,
    0x01, 0x01, 0x01, 0x01,
};

class _GraphArea :
    public OpenGl_Drawable
{
    public:
        double m_SelectionLeft;
        double m_SelectionRight;
        bool m_SelectionActive;

    public:
        _GraphArea(_GraphLayout& Layout);
        ~_GraphArea(void);
        _GraphLayout& m_Layout;

        // Properties
        bool m_MouseTrackingEnabled;


        double getXValue(_u32 XPosition);
        double getYValue(_u32 YPosition);
        _s32   getXPosition(double XValue);
        _s32   getYPosition(double YValue);
        double m_XMin, m_XMax, m_YMin, m_YMax;
        double m_XRange, m_YRange;

        void drawBackground(_u32 BorderSize, _u32 YAxisWidth, _u32 XAxisHeight, _u32 TitleHeight);
        void draw(_u32 BorderSize, _u32 YAxisWidth, _u32 XAxisHeight, _u32 TitleHeight, double XMin, double XMax, double YMin,
                  double YMax, map<int, _GraphData>& GraphData, CPoint CursorPosition);
        void drawBackground();
        bool getMouseTrackerEnabled();
        void enableMouseTracker(bool Enable);
        void setSelectionActive(bool Enable);

        void _GraphArea::drawZoomRect(CPoint Start, CPoint End);
        void _GraphArea::drawMouseTracker(CPoint CursorPosition, double MinX, double MaxX, double MinY, double MaxY,
                                          CRect GraphAreaRect);

        _u32 getHeight();
        _u32 getWidth();
};

